﻿Imports System
Imports System.IO
Imports System.Text

Public Class LogAuditoria

#Region "Variables"

    Private Shared strPathLog As String = "c:\temp\log\proveedores\logProveedores.csv"

#End Region

#Region "Funciones y Procedimientos"

    Public Shared Sub LogInfo(strUser As String, ByVal strClass As String, ByVal strText As String)
        Dim objFS As FileStream
        Dim objSW As StreamWriter

        Try
            objFS = New FileStream(strPathLog, FileMode.Append)
            objSW = New StreamWriter(objFS, Encoding.UTF8)

            objSW.WriteLine("{0} {1}, {2}, {3}, {4}", GetDate(), GetTime(), strUser, strClass, strText)
            objSW.WriteLine()

            objSW.Flush()
            objSW.Close()
        Catch ex As Exception

        Finally
            objFS = Nothing
            objSW = Nothing
        End Try
    End Sub

    Private Shared Function GetDate() As String
        Return String.Format("{0:yyyyMMdd}", Date.Now)
    End Function

    Private Shared Function GetTime() As String
        Return String.Format("{0:HH:mm:ss.fff}", Date.Now)
    End Function

#End Region

End Class